from rest_framework import serializers
from .models import Area


# 省級行政區序列化器
class AreaInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = Area
        fields = ("id","name")


# 子級行政區序列化器
class AreaSubsInfoSerializer(serializers.ModelSerializer):
    subs = AreaInfoSerializer(read_only=True,many=True)

    class Meta:
        model = Area
        fields = ("id","name","subs")